local MountCorePropStarRender = app.mvc.createRenderClass(...)

local IndexToNode = {1, 3, 5, 2, 4} -- 数据对应的Node
--data = Mount
function MountCorePropStarRender.create(node)
    if not node then
        return
    end
	local sprite = MountCorePropStarRender.extend(node)
	sprite:init()
	return sprite
end

function MountCorePropStarRender:init()
    self.super.init(self)
end


function MountCorePropStarRender:refresh()
    if not self._data then
        return
    end
    dump(self._data)
    self._ui["Panel/num"]:setString(self._data.starNum)
    self._ui["Panel/Panel_1/num"]:setString("+"..self._data.config.addType1)
    self._ui["Panel/Panel_2/num"]:setString("+"..self._data.config.addType3)
    self._ui["Panel/Panel_3/num"]:setString("+"..self._data.config.addType5)
    self._ui["Panel/Panel_4/num"]:setString("+"..self._data.config.addType2)
    self._ui["Panel/Panel_5/num"]:setString("+"..self._data.config.addType4)

    for i = 1, 5 do
        local numNode = self._ui["Panel/Panel_"..i]:getChildByName("num")
        if self._data.lastConfig then -- next
            local lastNum = self._data.lastConfig[ "addType"..IndexToNode[i] ]
            local targetNum = self._data.config[ "addType"..IndexToNode[i] ]
            if targetNum > lastNum then
                numNode:setColor(display.COLOR4_GREEN)
                display.setCascadeOpacityEnabled(numNode, false)
            else
                numNode:setColor(display.COLOR4_WHITE)
            end
        else -- cur
            if tonumber(numNode:getString()) == 0 then
                numNode:setColor(display.COLOR4_WHITE)
                numNode:setOpacity(255*0.5)
            else
                numNode:setColor(cc.c4b(255, 255, 132, 255))
            end
        end
    end
end

function MountCorePropStarRender:setTitle(title)
    self._ui["Panel/tlt"]:setString(title)
end

return MountCorePropStarRender